#!/bin/bash
clear

RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
PLAIN="\033[0m"

if [ "${EUID}" -ne 0 ]; then
    echo -e "${RED}You need to run this script as root!${PLAIN}" && exit 1
fi

read -p "Enter username: " USERNAME
read -p "Active duration: " ACTIVETIME
EXPDATE=$(date -d "$ACTIVETIME days" +"%F")
egrep "^$USERNAME" /etc/passwd >/dev/null
if [ $? -ne 0 ]; then
    echo -e "${RED}Username not exist!${PLAIN}" && exit 1
fi

passwd -u $USERNAME
usermod -e $EXPDATE $USERNAME
egrep "^$USERNAME" /etc/passwd >/dev/null
echo -e "$password\n$password" | passwd $USERNAME &>/dev/null

clear
echo echo "";
echo "=================== [ RENEW: ACCOUNT DETAIL ]"
echo -e "${YELLOW} Username:${PLAIN} ${GREEN}$USERNAME${PLAIN}"
echo -e "${YELLOW} Duration:${PLAIN} ${GREEN}$ACTIVETIME days${PLAIN}"
echo -e "${YELLOW}  Expired:${PLAIN} ${GREEN}$EXPDATE${PLAIN}"
echo "---------------------------------------------"
echo "Copyright 2021 Cybertize, Allright Reserved."
echo "============================================="
echo "";
